Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Микросервисы #26

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Микросервисы #26

wants to merge 9 commits into from

Conversation

AlGrItm
Copy link
Collaborator

@AlGrItm AlGrItm commented May 26, 2024

No description provided.

@GeorgiyX GeorgiyX self-requested a review May 26, 2024 18:37
Alex added 2 commits May 27, 2024 18:06
# Conflicts:
#	cmd/2024_1_ResCogitans/main.go
#	go.mod
#	go.sum
#	internal/delivery/handlers/authorization/auth_handler_test.go
#	internal/delivery/initialization/use_case_init.go
#	internal/storage/postgres/user/user_storage.go
#	internal/usecase/session_usecase.go
@@ -32,14 +21,24 @@ func main() {
}
logger.Info("Start config")

conn, err := grpc.Dial("localhost:8081", grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("did not connect: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему тут fatal, а не error? И почему используется пакет lag, а не наш логгер?

@@ -32,14 +21,24 @@ func main() {
}
logger.Info("Start config")

conn, err := grpc.Dial("localhost:8081", grpc.WithTransportCredentials(insecure.NewCredentials()))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давай в конфиг вынесем адрес

pdb, rdb, cdb, err := initialization.DataBaseInitialization()
if err != nil {
logger.Error("DataBase initialization error", "error", err)
return
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему тут решил убрать return? Мы же не можем работать без БД.

}

storages := initialization.StorageInit(pdb, rdb, cdb)
usecases := initialization.UseCaseInit(storages)
usecases := initialization.UseCaseInit(storages, conn)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давай клиент полностью проиннициализируем в main

pdb, rdb, cdb, err := initialization.DataBaseInitialization()
if err != nil {
logger.Error("DataBase initialization error", "error", err)
return
}

storages := initialization.StorageInit(pdb, rdb, cdb)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вообще ни из имени метода ни из имени переменной не понятно, что это за сторадж. Код должен быть самодокументируемым.


message GetSessionResponse {
int32 userID = 1;
string error = 2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Обычно если что-то идет не так ошибку возвращают средствами протокола

@@ -0,0 +1,37 @@
syntax = "proto3";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Т.к. у нас несколько сервисов в одном репозитории, предлагаю вынести код каждого сервиса в отдельную директорию. Внутри директории оставляем структуру описанную в project-layout. proto файлы следует размещать в /api.

return &SessionUseCase{
SessionStorage: storage,
client: gen.NewSessionServiceClient(conn),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давай клиента создавать в main функции

Comment on lines 45 to 47
if response.Error != "" {
return errors.New(response.Error)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Чуть выше писал - давай ошибки получать средствами протокола. Т.е. тут все ошибки должны проверяться через err

Comment on lines 19 to 30
func NewSessionStorage(client *redis.Client) *RedisStorage {
ctx, cancel := context.WithCancel(context.Background())
// Обеспечение освобождения ресурсов контекста при завершении работы
go func() {
<-ctx.Done()
cancel()
}()
return &RedisStorage{
client: client,
ctx: ctx,
mu: sync.Mutex{},
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вроде обсуждали что тут нужно поправить

Alex added 2 commits July 3, 2024 04:46
…е в env файл, доработка взаимодействия с микросервисом
…ого общего логгера во всех частях сервера, избавление от устаревших функций
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants